package com.itheima.springboot.service;

import com.itheima.springboot.mapper.UserMapper;
import com.itheima.springboot.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 何景航
 * @date 2024/12/17
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public User queryById(Long id){
        return userMapper.selectByPrimaryKey(id);
    }
    @Transactional
    public void saveUser(User user){
        System.out.println("新增用户...");
        userMapper.insertSelective(user);
//        int i = 1/0;
    }

}
